const express = require('express')
const router = express.Router()

const contentTagsController = require('../controller/ContentTagsController')

/**
 * @api {get} /api/v1/content/tags/list 获取标签列表
 * @apiDescription /api/v1/content/tags/list
 * @apiName list
 * @apiGroup Tags
 * @apiParam {string} [name]      标签名称
 * @apiParam {number} [page]      当前页
 * @apiParam {number} [pageSize]  分页大小
 * @apiSampleRequest /api/v1/content/tags/list
 * @apiSuccess {number} code 响应状态码
 * @apiSuccess {Tags[]} data 标签信息
 * @apiSuccessExample {json} Success-Response:
 *  HTTP/1.1 200 OK
 *  {
 *      "code" : 200,
 *      "data" : [
 *        {
            "tagId": 1,
            "name": "Java",
            "description": "Java是一门编程语言",
            "createdAt": "2023-09-01 12:22:33",
            "updatedAt": "2023-09-01 12:22:33",
 *        }
 *      ],
 *      "message" : "请求成功",Content
 *  }
 * @apiVersion v1.0.0
 */
router.get('/list', contentTagsController.tagsList)


/**
 * @api {get} /api/v1/content/tags/:id 根据id查询标签信息
 * @apiDescription /api/v1/content/tags/:id
 * @apiName getTagsById
 * @apiGroup Tags
 * @apiParam {number} id 标签id
 * @apiSampleRequest /api/v1/content/tags/:id
 * @apiSuccess {number} code 响应状态码
 * @apiSuccess {Tags} data 标签信息
 * @apiSuccessExample {json} Success-Response:
 *  HTTP/1.1 204 OK
 *  {
 *      "code" : 204,
 *      "data" :  {
            "tagId": 1,
            "name": "Java",
            "description": "Java是一门编程语言",
            "createdAt": "2023-09-01 12:22:33",
            "updatedAt": "2023-09-01 12:22:33",
 *        },
 *      "message" : "删除成功",
 *  }
 * @apiVersion v1.0.0
 */
router.get('/:id', contentTagsController.selectTagsById)


/**
 * @api {post} /api/v1/content/tags/add 添加标签
 * @apiDescription /api/v1/content/tags/add
 * @apiName add
 * @apiGroup Tags
 * @apiBody {string} name         标签名称
 * @apiBody {string} description  描述
 * @apiSampleRequest /api/v1/content/tags/add
 * @apiSuccess {number} code 响应状态码
 * @apiSuccess {Tags[]} data 标签信息
 * @apiSuccessExample {json} Success-Response:
 *  HTTP/1.1 201 OK
 *  {
 *      "code" : 201,
 *      "data" : true,
 *      "message" : "添加标签成功",
 *  }
 * @apiVersion v1.0.0
 */
router.post('/add', contentTagsController.addTags)


/**
 * @api {put} /api/v1/content/tags/update 修改标签
 * @apiDescription /api/v1/content/tags/update
 * @apiName update
 * @apiGroup Tags
 * @apiBody {number} tagId       标签id
 * @apiBody {string} name         标签名称
 * @apiBody {string} description  描述
 * @apiSampleRequest /api/v1/content/tags/update
 * @apiSuccess {number} code 响应状态码
 * @apiSuccess {Tags[]} data 标签信息
 * @apiSuccessExample {json} Success-Response:
 *  HTTP/1.1 208 OK
 *  {
 *      "code" : 208,
 *      "data" : true,
 *      "message" : "修改成功",
 *  }
 * @apiVersion v1.0.0
 */
router.put('/update', contentTagsController.updateTags)


/**
 * @api {delete} /api/v1/content/tags/delete 删除标签
 * @apiDescription /api/v1/content/tags/delete
 * @apiName delete
 * @apiGroup Tags
 * @apiBody {number} id 标签id
 * @apiSampleRequest /api/v1/content/tags/delete
 * @apiSuccess {number} code 响应状态码
 * @apiSuccess {Tags[]} data 标签信息
 * @apiSuccessExample {json} Success-Response:
 *  HTTP/1.1 204 OK
 *  {
 *      "code" : 204,
 *      "data" : true,
 *      "message" : "删除成功",
 *  }
 * @apiVersion v1.0.0
 */
router.delete('/delete', contentTagsController.deleteTags)

module.exports = router